package cn.tedu.ou;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class GuanYu {

    private String name="关二爷";

    // 之前都是编写具体的类型例如青龙偃月刀
    // 现在我们依赖Weapon接口,就能实现关羽使用所有Weapon接口的实现类对象
    //          这样就实现了方便更换武器的效果,实现的解耦操作
    @Autowired
    @Qualifier("dragonBlade")
    private Weapon weapon;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }

    public void fight(){
        System.out.println(name+"使用"+weapon+"战斗");
    }

}
